// @author U099151W Sun Chenchen
// all functions in this file  are implemented by the author unless specifically indicated
var Rebel  = function() {
    NPC.call(this);
    this.weaponType = 0;
    this.fitness = 50;
    this.rateOfInfluence = 0.5;
    this.arrayOfInfluence = new Array();
    this.currentFightOutcome = "never_fought";
    this.drawDebug = function(context, sx, sy, w, h) {
        context.save();
        context.fillStyle = "yellow";
        context.fillRect(sx, sy, w, h);

        context.translate(sx, sy);
        var type = this.getType();
        context.fillStyle = "black";
        context.translate(0, 10);
        context.fillText(this.getType(), 0, 0);
        context.fillText(this.eventType, 0, 10);
        if (type === "Army" || type === "Rebel") {
            context.fillText("Weapon Level  " + this.weaponType, 0, 20);
        } else {
            context.fillText("No Weapon", 0, 20);
        }
        if (type === "Citizen") {
            context.fillText("Influenced " + this.rateAtWhichCanBeInfluenced.toFixed(3), 00, 30);
        } else if (type === "Rebel" || type === "Spy") {
            context.fillText("Influence " + this.rateOfInfluence.toFixed(3), 00, 30);
        } else if (type === "Army") {
            context.fillText("War!", 0, 30);
        } else if (type === "Merchant") {
            context.fillText("Whatever!", 0, 30);
        }

        context.restore();
    };
    this.updateSprite = function(eventType) {
        var newState;
        switch (eventType) {
            case "two_rebels_talking" :
                newState = {
                    action : "Influence",
                    length : 2
                };
                this.setState(newState);
                break;
            case "fighting" :
                newState = {
                    action : "Fight",
                    length : 2
                };
                this.setState(newState);
                break;
            case "purchasing" :
                newState = {
                    action : "Purchase",
                    length : 2
                };
                this.setState(newState);
                break;
            case "influencing" :
                newState = {
                    action : "Influence",
                    length : 2
                };
                this.setState(newState);
                break;
            default :
                break;
        }
    }
};
Rebel.prototype = new NPC();
Rebel.prototype.constructor = Rebel;